<template>
    <el-select
        :value="value"
        :loading="!options"
        loading-text="^^^ 正在请求数据 ^^^"
        v-bind="config.props"
        v-on="$listeners">
        <el-option
            v-for="(item,index) in options" :key="index"
            :label="item[config.label]"
            :value="item[config.value]">
        </el-option>
    </el-select>
</template>

<script>
    import AsyncOptionsFrame from './AsyncOptionsFrame'

    export default {
        extends: AsyncOptionsFrame,
        inject: ['dForm'],
        created() {
            // 临时功能，准备删除
            const watch = this.config.watch
            if (watch) {
                for (let k in watch) {
                    if (typeof watch[k] !== 'function') continue
                    this.$watch('dForm.model.' + k, (newVal, oldVal) => {
                        watch[k].call(this, newVal, oldVal, this.loadOptions)
                    }, {
                        deep: true,
                    })
                }
            }
        },
    }
</script>

<style lang="scss" scoped>

</style>
